~ chicken-core (master) /manual/Module (chicken bytevector)


  1[[tags: manual]]
  2[[toc:]]
  3
  4== Module (chicken bytevector)
  5
  6This module contains procedures for dealing with "bytevectors",
  7fixed-size sequences of unsigned 8-bit integers.
  8
  9=== bytevector
 10
 11<procedure>(bytevector FIXNUM ...)</procedure>
 12
 13Returns a new bytevector containing the values {{FIXNUM ...}}.
 14
 15=== make-bytevector
 16
 17<procedure>(make-bytevector SIZE)</procedure>
 18
 19Returns a bytevector object of {{SIZE}} bytes, aligned on an 8-byte boundary,
 20uninitialized.
 21
 22=== bytevector?
 23
 24<procedure>(bytevector? X)</procedure>
 25
 26Returns {{#t}} if {{X}} is a bytevector object, or
 27{{#f}} otherwise.
 28
 29=== bytevector-length
 30
 31<procedure>(bytevector-length BYTEVECTOR)</procedure>
 32
 33Returns the number of bytes in {{BYTEVECTOR}}.
 34
 35=== bytevector-u8-ref
 36
 37<procedure>(bytevector-u8-ref BYTEVECTOR INDEX)</procedure>
 38
 39Returns the byte at {{INDEX}} in {{BYTEVECTOR}}.
 40
 41=== bytevector-u8-set!
 42
 43<procedure>(bytevector-u8-set! BYTEVECTOR INDEX VALUE)</procedure>
 44
 45Destructively modifies the byte at {{INDEX}} in {{BYTEVECTOR}} to {{VALUE}}, which
 46should be a fixnum.
 47
 48=== utf8->string
 49
 50<procedure>(utf8->string BYTEVECTOR [VALIDATE])</procedure>
 51
 52Returns a string with the contents of {{BYTEVECTOR}}. if {{VALIDATE}}
 53is given and false, then invalidly
 54encoded characters do not signal an error - byte-sequences that do no represent
 55valid UTF-8 characters are retained and, if extracted with {{string-ref}}
 56are converted to a trailing surrogate pair half in the range U+DC80 to U+DCFF.
 57
 58=== string->utf8
 59
 60<procedure>(string->utf8 STRING)</procedure>
 61
 62Returns a bytevector with the contents of {{STRING}}.
 63
 64=== latin1->string
 65
 66<procedure>(latin1->string BYTEVECTOR)</procedure>
 67
 68Returns a string with the contents of {{BYTEVECTOR}} converted from Latin-1 (ISO-8859-1) encoding to UTF-8. 
 69
 70=== string->latin1
 71
 72<procedure>(string->latin1 STRING)</procedure>
 73
 74Returns a bytevector with the contents of {{STRING}} encoded as Latin-1 (ISO-?8859-1).
 75
 76=== bytevector=?
 77
 78<procedure>(bytevector=? BYTEVECTOR1 BYTEVECTOR2)</procedure>
 79
 80Returns {{#t}} if the two argument bytevectors are of the same
 81size and have the same content.
 82
 83=== bytevector-append
 84
 85<procedure>(bytevector-append BYTEVECTOR ...)</procedure>
 86
 87Returns a new bytevector holding the concatenated contents of all
 88argument bytevectors.
 89
 90=== bytevector-copy
 91
 92<procedure>(bytevector-copy BYTEVECTOR #!optional START END)</procedure>
 93
 94Returns a new bytevector holding the contents of {{BYTEVECTOR}} between
 95the indices {{START}} to {{END}}.
 96
 97=== bytevector-copy!
 98
 99<procedure>(bytevector-copy! TO AT FROM #!optional START END)</procedure>
100
101Copioes the contents of the bytevector FROM between
102the indices {{START}} to {{END}} into the bytevector {{TO}}, starting at
103index {{AT}}.
104
105
106---
107Previous: [[Module (chicken bitwise)]]
108
109Next: [[Module (chicken condition)]]
110
111
Trap